#include <iostream>

using namespace std;
const int N=1e6+10;

int a[N];
struct node{
	int l,r;
	int minn;
}tr[N*4];

void pushup(int u)
{
	tr[u].minn=min(tr[u<<1].minn,tr[u<<1|1].minn);
	
}
void build(int u,int l,int r)
{
	if(l==r)
	{
		tr[u]={l,r,a[l]};
	}
	else{
		tr[u]={l,r};
		int mid=l+r>>1;
		build(u<<1,l,mid);
		build(u<<1|1,mid+1,r);
		pushup(u);
	}
}
int query(int u,int l,int r)
{
	if(tr[u].l>=l && tr[u].r<=r)
	{
		return tr[u].minn;
	}	
	
	int mid=tr[u].l+tr[u].r>>1;
	int ret=N;
	if(l<=mid)
	{
		ret=query(u<<1,l,r);
	}
	if(r>mid)
	{
		ret=min(ret,query(u<<1|1,l,r));
	}
	return ret;
}
int main()
{
	int n,k;
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	cin>>k;
	build(1,1,n);
	for(int i=1;i<=n;i++)
	{
		if(i==1)
			cout<<query(1,max(1,i-k),min(n,i+k));
		else
			cout<<' '<<query(1,max(1,i-k),min(n,i+k));	
	}
	return 0;
}
